﻿using System.Xml.Linq;

namespace Game {
    public class RCModLoader : ModLoader {
        public override void __ModInitialize() {
            ModsManager.RegisterHook("OnMainMenuScreenCreated", this);
            ModsManager.RegisterHook("PlayInGameMusic", this);
            ModsManager.RegisterHook("LoadSettings", this);
            ModsManager.RegisterHook("SaveSettings", this);
            RuthlessConquest.SettingsManager.Initialize();
        }

        public override void OnMainMenuScreenCreated(MainMenuScreen mainMenuScreen, StackPanelWidget leftBottomBar, StackPanelWidget rightBottomBar) {
            rightBottomBar.AddChildren(new RCEntryButton());
        }

        public override void PlayInGameMusic() {
            if (ScreensManager.CurrentScreen is RuthlessConquest.MainMenuScreen
                && !MusicManager.IsPlaying) {
                MusicManager.PlayMusic("RCSounds/SpeedOfLight", 0f);
            }
        }

        public override void LoadSettings(XElement xElement) {
            RuthlessConquest.SettingsManager.LoadSettings(xElement);
        }

        public override void SaveSettings(XElement xElement) {
            RuthlessConquest.SettingsManager.SaveSettings(xElement);
        }
    }
}